import Cookies from 'js-cookie'

const ry = {
  state: {
    cgzry: {
      G11: 0,
      G23: 0,
      G24: 0,
      G34: 0,
      G43: 0,
      G44: 0,
      G48: 0,
      G52: 0,
      G54: 0,
      G55: 0
    },
    scr: {
      G10: 0,
      G19: 0,
      G20: 0,
      G24: 0,
      G28: 0,
      G30: 0,
      G31: 0
    },
    icer: {
      G10: 0,
      G19: 0,
      G20: 0,
      G24: 0,
      G28: 0,
      G30: 0,
      G31: 0
    },
    yry: {
      G4: 0
    },
    rq: {
      G4: 0,
      G23: 0,
      G24: 0,
      G34: 0,
      G43: 0,
      G44: 0,
      G48: 0,
      G52: 0,
      G54: 0,
      G55: 0
    }
  },
  mutations: {
    UPDATE_CGZRY(state, numbers) {
      const keys = Object.keys(numbers)
      const values = Object.values(numbers)
      state.cgzry.keys = values[0]
      Cookies.set('cgzry.' + keys[0], values[0])
    },
    UPDATE_SCR(state, numbers) {
      const keys = Object.keys(numbers)
      const values = Object.values(numbers)
      state.scr.keys = values[0]
      Cookies.set('scr.' + keys[0], values[0])
    },
    UPDATE_ICER(state, numbers) {
      const keys = Object.keys(numbers)
      const values = Object.values(numbers)
      state.icer.keys = values[0]
      Cookies.set('icer.' + keys[0], values[0])
    },
    UPDATE_YRY(state, numbers) {
      const keys = Object.keys(numbers)
      const values = Object.values(numbers)
      state.yry.keys = values[0]
      Cookies.set('yry.' + keys[0], values[0])
    }
  },
  actions: {
    UPDATE_CGZRY(context, numbers) {
      context.commit('UPDATE_CGZRY', numbers)
    },
    UPDATE_SCR(context, numbers) {
      context.commit('UPDATE_SCR', numbers)
    },
    UPDATE_ICER(context, numbers) {
      context.commit('UPDATE_ICER', numbers)
    },
    UPDATE_YRY(context, numbers) {
      context.commit('UPDATE_YRY', numbers)
    }
  }
}

export default ry
